package com.gomore.opple.module.addaddress;

import android.os.Bundle;

import com.gomore.opple.R;
import com.gomore.opple.module.BaseActivity;
import com.gomore.opple.module.IntentStart;
import com.gomore.opple.web.cgform.shippingaddr.entity.TOShippingAddrEntity;

import javax.inject.Inject;

/**
 * Created by asus on 2017/5/9.
 */
public class AddAddressActivity extends BaseActivity {
    @Inject
    AddAddressPresenter addAddressPresenter;

    private AddAddressFragment addAddressFragment;
    private TOShippingAddrEntity toShippingAddrEntity;

    @Override
    protected void initalizeViewData() {
        super.initalizeViewData();
        if (getIntent() != null) {
            toShippingAddrEntity = (TOShippingAddrEntity) getIntent().getSerializableExtra(IntentStart.ADDRESS);
        }
    }

    @Override
    protected void initalizeViews() {
        if (addAddressFragment == null) {
            addAddressFragment = AddAddressFragment.getInstance();
            Bundle bundle = new Bundle();
            bundle.putSerializable(IntentStart.ADDRESS, toShippingAddrEntity);
            addAddressFragment.setArguments(bundle);
            replaceFragment(addAddressFragment, false, "add_address_view");
        }
    }

    @Override
    protected void initializeDependencyInjector() {
        DaggerAddAddressComponent.builder()
                .dataRepositoryComponent(getRepositoryComponent())
                .addAddressPresenterModule((new AddAddressPresenterModule(addAddressFragment)))
                .build()
                .inject(this);
    }

    @Override
    protected int getLayoutView() {
        return R.layout.activity_add_address;
    }

}
